﻿/*
* DrawFunc.cs
*
* 功 能： 整合数据描图模块的一些业务方法类
* 类 名： DrawFunc
*
* Ver    变更日期  20131126   负责人  黄永生  变更内容
* ───────────────────────────────────
*/
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using DQYT.HTDZ.Common;
using DQYT.HTDZ.Model;
using DQYT.HTDZ.BLL;
using System.Data;
using DQYT.HTDZ.BusinessService;
using Maticsoft.DBUtility;

namespace DQYT.HTDZ.BusinessService
{
    /// <summary>
    /// 数据描图的一些业务方法
    /// </summary>
   public  class DrawFunc
    {
       public DrawFunc()
       { 

       }

       /// <summary>
       /// 获得同一时间段的所有井数据
       /// </summary>
       /// <param name="time"></param>
       /// <returns></returns>
       public DataTable getWellList_Date(string time_s,string time_e)
       {
           DataSet ds = new DataSet();
           //string strWhere = "JCRQ between to_date( '" + time_s + "','yyyy-MM-dd HH24:mi:ss ') and to_date('" + time_e + "','yyyy-MM-dd HH24:mi:ss')";
           //BDDATESOURSEBLL bll = new BDDATESOURSEBLL();
           //ds = bll.GetList(strWhere);
           //return ds.Tables[0];
           string sqlstr = "select ID,WELLID,JCRQ  FROM BDDATESOURSE where JCRQ between to_date( '" + time_s + "','yyyy-MM-dd HH24:mi:ss ') and to_date('" + time_e + "','yyyy-MM-dd HH24:mi:ss') order by JCRQ";
           BDDATESOURSEBLL bll = new BDDATESOURSEBLL();
           ds = bll.GetList_SQL(sqlstr);
           return ds.Tables[0];
       }
       /// <summary>
       /// 获得同一时间段的单井数据
       /// </summary>
       /// <param name="time"></param>
       /// <returns></returns>
       public DataTable getWellList_DateAndID(string time_s, string time_e,string wellid)
       {
           DataSet ds = new DataSet();
           string sqlstr = "select ID,WELLID,JCRQ FROM BDDATESOURSE where JCRQ between to_date( '" + time_s + "','yyyy-MM-dd HH24:mi:ss ') and to_date('" + time_e + "','yyyy-MM-dd HH24:mi:ss') and WELLID='" + wellid + "' order by JCRQ";
           BDDATESOURSEBLL bll = new BDDATESOURSEBLL();
           ds = bll.GetList_SQL(sqlstr);
           return ds.Tables[0];
       }
       /// <summary>
       /// 获得井号列表
       /// </summary>
       /// <returns></returns>
       public DataTable getWellidList()
       {
           DataSet ds = new DataSet();
           string sqlstr = "select  distinct WELLID FROM BDDATESOURSE";
           BDDATESOURSEBLL bll = new BDDATESOURSEBLL();
           ds = bll.GetList_SQL(sqlstr);
           return ds.Tables[0];
       }
       /// <summary>
       /// 获得用户上次操作的最新时间
       /// </summary>
       /// <returns></returns>
       public DataTable getcurJCRQ()
       {
           DataSet ds = new DataSet();
           string sqlstr = "select JCRQ  FROM BDDATESOURSE  where ROWNUM<=2 order by JCRQ";
           BDDATESOURSEBLL bll = new BDDATESOURSEBLL();
           ds = bll.GetList_SQL(sqlstr);
           return ds.Tables[0];
       }
       /// <summary>
       /// 获得最新的井号和检测日期
       /// </summary>
       /// <returns></returns>
       public DataTable getcurdata()
       {
           DataSet ds = new DataSet();
           string sqlstr = "select ID,WELLID,JCRQ FROM BDDATESOURSE  order by JCRQ DESC";
           BDDATESOURSEBLL bll = new BDDATESOURSEBLL();
           ds = bll.GetList_SQL(sqlstr);
           return ds.Tables[0];
       }

       public DataTable getcurdata(int pageSize,int pageIndex,out int recordCount)
       {
           DataTable dt = new DataTable();
           string sqlstr = "select ID,WELLID,JCRQ FROM BDDATESOURSE  order by JCRQ DESC";
           dt= DbHelperOra.ExecutePageQuery(sqlstr, pageSize, pageIndex, out recordCount);
          
           return dt;
       }



       /// <summary>
       /// 获得同一时间段的单井数据
       /// </summary>
       /// <param name="time"></param>
       /// <returns></returns>
       public DataTable getWellList_DateAndID(string time_s, string time_e, string wellid, int pageSize, int pageIndex, out int recordCount)
       {
           DataTable dt = new DataTable();
           string sqlstr = "select ID,WELLID,JCRQ FROM BDDATESOURSE where JCRQ between to_date( '" + time_s + "','MM/dd/yyyy HH24:mi:ss') and to_date('" + time_e + "','MM/dd/yyyy HH24:mi:ss') and WELLID='" + wellid + "' order by JCRQ DESC";
           //BDDATESOURSEBLL bll = new BDDATESOURSEBLL();
           //ds = bll.GetList_SQL(sqlstr);
           dt = DbHelperOra.ExecutePageQuery(sqlstr, pageSize, pageIndex, out recordCount);
           return dt;
       }

       /// <summary>
       /// 获得同一时间段的所有井数据
       /// </summary>
       /// <param name="time"></param>
       /// <returns></returns>
       public DataTable getWellList_Date(string time_s, string time_e, int pageSize, int pageIndex, out int recordCount)
       {
           DataTable dt = new DataTable();
           //string strWhere = "JCRQ between to_date( '" + time_s + "','yyyy-MM-dd HH24:mi:ss ') and to_date('" + time_e + "','yyyy-MM-dd HH24:mi:ss')";
           //BDDATESOURSEBLL bll = new BDDATESOURSEBLL();
           //ds = bll.GetList(strWhere);
           //return ds.Tables[0];
           string sqlstr = "select ID,WELLID,JCRQ  FROM BDDATESOURSE where JCRQ between to_date( '" + time_s + "','MM/dd/yyyy HH24:mi:ss') and to_date('" + time_e + "','MM/dd/yyyy HH24:mi:ss') order by JCRQ DESC ";
           dt = DbHelperOra.ExecutePageQuery(sqlstr, pageSize, pageIndex, out recordCount);
           //BDDATESOURSEBLL bll = new BDDATESOURSEBLL();
           //ds = bll.GetList_SQL(sqlstr);
           return dt;
       }


    }
}
